<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>

<script>
import { GET_AUTH } from './api'

export default {
    mounted: function() {
        if (!this.$store.state.authToken) {//get clean after close or refresh//TODO:be presistent
            this.$router.replace('login')
        } else {
            GET_AUTH.then(response => {
                if (!response.data || this.$store.state.username != response.data) {
                    this.$router.replace('login')
                } else {
                    this.$router.replace('manage')
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
#app {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}
</style>
